Chuyển tới nội dung chính

String

1/ For a new line in the string: \n​

print("Hey \n baby")

Hey baby

2/ For a tab: \t​

print("Hey \t baby")

Hey baby

print("Hey \\ baby")

Hey \ baby


METHOD​

1/ .upper()​

A = "i can't help it but fall in love with you"
B = A.upper()
print(B)

I CAN'T HELP IT BUT FALL IN LOVE WITH YOU

2/ .replace()​

A = "kevinph4n is handsome-ish"
B = A.replace('handsome-ish', 'handsome')
print(B)

kevinph4n is handsome

3/ .find() | The output would be the first index of the string​

name = "Kevin Phan"
A = name.find('Phan')
B = name.find('Kevin')
print(A)
print(B)

6 0

4/ .title()​

name = "im a beast iykyk"
A = name.title()
print(A)

Im A Beast Iykyk


PRACTICES​

1/​

print("AB\nC\nDE")

AB C DE

2/​

"heyPhan".find("Phan")

3

3/​

Name = "Kevin Phan" Name[-1] would be? -> Answer: n

4/​

A = "python basics kevinph4n"
B = A.title()
print(B)

Python Basics Kevinph4N